fix: avoid Cloudflare 403 for urllib vision requests - #21
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9f8d0505b5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Problem
The shared Python vision client relied on urllib's default
Python-urllib/3.xUser-Agent. Cloudflare-backed OpenAI-compatible endpoints such as OpenCode Go can reject that signature with HTTP 403 / error code 1010 even when the same request, key, body, and model succeed with a browser-compatible User-Agent.PR #13 also touches User-Agent behavior, but its current implementation hardcodes
agent-vision-toolkit/0.1, provides no override, and is part of a broader Responses API change that still has requested changes. This PR is the minimal standalone bug fix for the confirmed 403 path; it does not duplicate the protocol or proxy features in #13.Changes
vision_client.py.VISION_USER_AGENT.Verification
Before the fix, a local fixture that rejects
Python-urllib/*reproduced:After the fix, the same fixture returned
okwith the configured browser-compatible default User-Agent.Required repository checks passed:
python3 -m py_compile vision_proxy.py vision_client.py ground.py detect.py bin/glance bin/trace bin/croppython3 tests/test_image_rewrite_shapes.pypython3 tests/test_focus_hint.pypython3 tests/test_anthropic_rewrite.pypython3 tests/smoke_test_proxy.pypython3 tests/test_vision_client.pygit diff --checkThis is a non-UI HTTP-client change, so there is no meaningful browser path; the substitute end-to-end verification is the local HTTP fixture exercising the affected User-Agent/403 request path.
Fixes #19